extends "../cTDZ_2_2/cTDZ_2_2.gd"
func _info():
	pass

func _connect():
	._connect()

func _extInit():
	._extInit()
	chaName = "骷髅骑士"
	lv = 3
	attCoe.atkRan = 2
	attCoe.atk = 31.5 / 8.5 * 2 / 3
	attCoe.maxHp = 950 / 112.5 / 3
	attCoe.def = 55 / 15.0 / 2
	attCoe.mgiDef = 55 / 16.6 / 2 
	addCdSkill("klqs1",8)
	addCdSkill("klqs",11)
	addSkillTxt("战马冲刺：冲向敌方生命值最低的单位，对其造成180%物理伤害，并对路径上的敌人造成50%物理伤害[cd:8秒]")
	addSkillTxt("亡灵凝视：嘲讽攻击范围内所有敌人，并为自己添加50点防御和20%减伤，持续6秒[cd:11秒]")

func _castCdSkill(id):
	._castCdSkill(id)
	if id == "klqs":
		cst("亡灵凝视","000000",position)
		self.addBuff(BF.new(1))
		var chas = getAllChas(1)
		for i in chas:
			if inrange(i.cell,cell,att.atkRan):
				i.aiCha = self

	if id == "klqs1":
		cst("战马冲刺","000000",position)
		var chas = getAllChas(1)
		chas.sort_custom(self,"sort")
		var cells = self.cell
		jump(chas[0],self)
		hurtChara(chas[0],att.atk*1.8,Chara.HurtType.MGI,Chara.AtkType.SKILL)
		var chas2 = utils.lineChas(cells,cell,20)
		#print("+++++++++")
		for i in chas2:
		#	print(i.id)
			if i == chas[0] || i == self || i.team == self.team:continue
			hurtChara(i,att.atk*0.5,Chara.HurtType.PHY,Chara.AtkType.SKILL)
		#print("+++++++++")
			
func sort(a,b):
	return a.att.hp < b.att.hp

func inrange(a,b,c):
	var x = abs(a.x - b.x)
	var y = abs(a.y - b.y)
	return x*x + y*y <= c*c

class BF:
	extends Buff
	func _init(lv):
		attInit()
		life = lv * 6
		att.def = 50
		att.mgiDef = 50
		att.defR = 0.2